<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        var str = 'oabcoefoxyozzopp';
        var o = {};
        for (var i = 0; i < str.length; i++) {
            var chars =  str.charAt(i);//chars是字符串的每一个字符
            if (o[chars]){//o[chars] 得到是属性值
                o[chars]++;
            }else {
                o[chars] = 1;
            }
        }
        console.log(o);
        //2.遍历对象
        var max = 0;
        var ch = '';
        for (var k in o){
            //k 得到的属性名
            //o[k] 得到的是属性值
            if (o[k] > max){
                max = o[k];
                ch = k;
            }
        }
        console.log(max);
        console.log('最多的字符是'+ch);
        // console.log(num);
    </script>
</head>
<body>

</body>
</html>